home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / BGUI11c.lha / AmigaE / examples / test.e < prev   
Text File  |  1994-12-24  |  6KB  |  136 lines

  1. ;/* Execute me to compile.
  2. ec test
  3. quit
  4. */
  5. /*
  6. **      A small example of BGUI in Amiga E.
  7. **
  8. **      I have little knowledge of the E language so
  9. **      please forgive me if something is wrong or if
  10. **      something could have been done easier.
  11. **/
  12. OPT OSVERSION=37
  13. OPT PREPROCESS
  14.  
  15. MODULE 'libraries/bgui',
  16.        'libraries/bgui_macros',
  17.        'libraries/gadtools',
  18.        'bgui',
  19.        'tools/boopsi',
  20.        'utility/tagitem',
  21.        'intuition/classes',
  22.        'intuition/classusr',
  23.        'intuition/gadgetclass'
  24.  
  25. /*
  26. **      Quit gadget/menu ID.
  27. **/
  28. CONST   ID_QUIT = 1
  29.  
  30. /*
  31. **      And were off.
  32. **/
  33. PROC main()
  34.         DEF     wd_obj, running = TRUE, rc = 0, signal
  35.         DEF     gd_quit, info_text : PTR TO CHAR
  36.  
  37.         /*
  38.         **      Text for the information class object.
  39.         **/
  40.         info_text := '\ecThis demonstration program shows you\n'+
  41.                      'how you can use BGUI with \ebAmiga E\en.\n\n' +
  42.                      'Since I only have little knowledge about this\n' +
  43.                      'language it might be possible that the code\n' +
  44.                      'looks a bit strange to you. Sorry...'
  45.  
  46.         /*
  47.         **      Open the library.
  48.         **/
  49.         IF bguibase := OpenLibrary( 'bgui.library', 37 )
  50.                 /*
  51.                 **      Create a window object.
  52.                 **/
  53.                 wd_obj := WindowObject,
  54.                         WINDOW_TITLE,         'BGUI in Amiga E',
  55.                         /*
  56.                         **    A very small menu strip.
  57.                         **/
  58.                         WINDOW_MENUSTRIP,
  59.                                 [ NM_TITLE, 0, 'Project', NIL, 0, 0, NIL,
  60.                                   NM_ITEM,  0, 'Quit',    'Q', 0, 0, ID_QUIT,
  61.                                   NM_END,   0, NIL,       NIL, 0, 0, NIL ] : newmenu,
  62.                         WINDOW_AUTOASPECT,      TRUE,
  63.                         WINDOW_MASTERGROUP,
  64.                                 /*
  65.                                 **      A vertical master group.
  66.                                 **/
  67.                                 VGroupObject, Spacing( 4 ), HOffset( 4 ), VOffset( 4 ), GROUP_BACKFILL, SHINE_RASTER,
  68.                                         StartMember,
  69.                                                 InfoFixed( NIL, info_text, NIL, 6 ),
  70.                                         EndMember,
  71.                                         StartMember,
  72.                                                 HGroupObject,
  73.                                                         VarSpace( DEFAULT_WEIGHT ),
  74.                                                         StartMember, gd_quit := KeyButton( '_Quit', ID_QUIT ), EndMember,
  75.                                                         VarSpace( DEFAULT_WEIGHT ),
  76.                                                 EndObject, FixMinHeight,
  77.                                         EndMember,
  78.                                 EndObject,
  79.                         EndObject
  80.  
  81.                 /*
  82.                 **      Object created OK?
  83.                 **/
  84.                 IF wd_obj
  85.                         /*
  86.                         **      Attach hotkey for the quit gadget.
  87.                         **/
  88.                         IF GadgetKey( wd_obj, gd_quit, 'q' )
  89.                                 /*
  90.                                 **      Open up the window.
  91.                                 **/
  92.                                 IF WindowOpen( wd_obj )
  93.                                         /*
  94.                                         **      Obtain signal mask.
  95.                                         **/
  96.                                         GetAttr( WINDOW_SIGMASK, wd_obj, {signal} )
  97.                                         /*
  98.                                         **      Poll messages.
  99.                                         **/
  100.                                         WHILE running = TRUE
  101.                                                 /*
  102.                                                 **      Wait for the signal.
  103.                                                 **/
  104.                                                 Wait( signal )
  105.                                                 /*
  106.                                                 **      Call uppon the event handler.
  107.                                                 **/
  108.                                                 WHILE ( rc := HandleEvent( wd_obj )) <> WMHI_NOMORE
  109.                                                         SELECT rc
  110.                                                                 CASE    WMHI_CLOSEWINDOW
  111.                                                                         running := FALSE
  112.                                                                 CASE    ID_QUIT
  113.                                                                         running := FALSE
  114.                                                         ENDSELECT
  115.                                                 ENDWHILE
  116.                                         ENDWHILE
  117.                                 ENDIF
  118.                         ELSE
  119.                                 WriteF( 'Unable to attach hotkeys\n' );
  120.                         ENDIF
  121.                         /*
  122.                         **      Disposing of the object
  123.                         **      will automatically close the window
  124.                         **      and dispose of all objects that
  125.                         **      are attached to the window.
  126.                         **/
  127.                         DisposeObject( wd_obj )
  128.                 ELSE
  129.                         WriteF( 'Unable to create a window object\n' )
  130.                 ENDIF
  131.                 CloseLibrary(bguibase)
  132.         ELSE
  133.                 WriteF( 'Unable to open the bgui.library\n' )
  134.         ENDIF
  135. ENDPROC NIL
  136.